const app = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    typename:'请选择会员',
    nianxian:1,
    jine:6800,
    zong:6800,
    hylist:[],
    hyindex:0,
    id:0,
    showTk:false,
    showXy:true,
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.setData({
      id:options.id
    })
    var that = this;
    var url = "api/FeijiuApp/GetUserRanks?strRSA=";
    app.getDaoGet(url, function (r) {
      if (r.code == 200) { 
        
        var hylist = r.data;
        var ind = 0;
        for (var i = 0; i < hylist.length; i++) {         
          if (hylist[i].RankID == options.id) {
              ind = i;
          }
        }       
        that.setData({
          hylist:r.data,
          jine:r.data[ind].RankPrice,
          zong:r.data[ind].RankPrice,
          hyindex:ind
        })
      }
    }) 

  },
  xxadd:function () {
    var nianx = this.data.nianxian;
    var jine = this.data.jine;
    if (nianx < 5) {
      this.setData({
        nianxian:nianx+1,
        zong:jine*(nianx+1)
      })
    }else{
      this.setData({
        nianxian:5,
        zong:jine*5
      })      
    }
  },
  xxjian:function () {
    var nianx = this.data.nianxian;
    var jine = this.data.jine;
    if (nianx > 1) {
      this.setData({
        nianxian:nianx-1,
        zong:jine*(nianx-1)
      })
    }else{
      this.setData({
        nianxian:1,
        zong:jine*1
      })      
    }
  },  
  pickerSelected:function (e) {
    var hylist = this.data.hylist;
    var index = e.detail.value;
    this.setData({
      hyindex:e.detail.value,
      id:hylist[index].RankID,
      nianxian:1,
      jine:hylist[index].RankPrice,
      zong:hylist[index].RankPrice,      
    })
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },
  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },
  getGetUserRanks:function () {

  },
  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  },
  hetong:function () {
    wx.navigateTo({
      url: 'hetong?id='+this.data.id+'&nianxian='+this.data.nianxian
    })
  },
  toweb_view:function (e) {
    wx.navigateTo({
      url: 'toweb?url='+e.currentTarget.dataset.url
    })
  },
  showTk:function () {
    this.setData({
      showTk:!this.data.showTk
    })
  },
  showXy:function () {
    this.setData({
      showXy:!this.data.showXy
    })
  }
})